//生产管理系统/数据趋势分析/填表
import React, { Component } from "react";
import { connect } from "dva";

import {
    Form,
    Radio,
    Modal,
    Table,
    Select,
    Cascader,
    DatePicker,
    Dropdown,
    Button,
    Icon,
    message,
    Pagination,
    Input,
    TimePicker
} from "antd";
import moment from "moment";
const { TextArea } = Input;


//form表单套件
const FormItem = Form.Item;
const { MonthPicker, RangePicker } = DatePicker;
const CollectionCreateForm = Form.create()(
    class extends React.Component {

        state = {
          checkNick:false,
          checkNick1:false
        }

        handleChange = (e) => {
               if(e == null) {
                this.setState({
                    checkNick:false
                   })
               } 
               if(e){
                this.setState({
                    checkNick:true
                   })
               }
                console.log(321);
        }
        handleChange1 = (e) => {
            if(e == null) {
             this.setState({
                 checkNick1:false
                })
            } 
            if(e){
             this.setState({
                 checkNick1:true
                })
            }
             console.log(321);
     }

        disabledDate = (current) => {
            return  current > moment().endOf('day');
        }

        onShowChange = (type, e) => {
            let value = e.target.value;
           
            
                this.setState({
                    [type]: value
                })
           
            
            console.log("type:", value);
        }


      onCreate = () => {
        
      }

      
      
        handleSubmit = e => {
            e.preventDefault();
            this.props.form.validateFields((err, fieldsValue) => {
               
              console.log(fieldsValue)
              
               
            });
        };

        render() {
            const { getFieldDecorator,setFieldsValue } = this.props.form;
            const format = 'HH'
           
            const data = {
              rules: [
                  { required: true, message: "请选择日期!" }
              ]
            };
          
           
            const { visible, onCancel, onCreate, form ,text} = this.props;
           
           if(text == "能源消耗统计表") {
            return (
              <Modal
                  destroyOnClose={true}
                  visible={visible}
                  title="新增记录"
                  okText="保存"
                  cancelText="关闭"
                  onCancel={onCancel}
                  onOk={onCreate}
              >
              
                  <Form layout="inline">
                      <FormItem label="日期">
                          {getFieldDecorator("nydata" ,data)(
                              <DatePicker placeholder="请选择日期"
                              disabledDate={this.disabledDate}
                                // disabledTime={disabledDateTime}
                                // showTime={{ defaultValue: moment('00:00:00', 'HH:mm:ss') }}
                              />
                          )}
                      </FormItem>
                      <FormItem label="时间">
                          {getFieldDecorator("nytime",data)(
                              <TimePicker format={format}  placeholder="请选择时间"/>
                          )}
                      </FormItem>
                      <FormItem label="燃气抄表值/Nm³">
                          {getFieldDecorator("useNaturalGas",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input  size="small" />
                          )}
                      </FormItem>
                      <FormItem label="电耗抄表值/KWh">
                          {getFieldDecorator("useElectric",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="水耗抄表值/t">
                          {getFieldDecorator("useWater",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="记录人">
                          {getFieldDecorator("opertion",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
               
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="备注">
                          {getFieldDecorator("remarkText",{
            validateTrigger: [ 'onBlur','onChange'],
            rules: [
               {max:20,message:"最多输入20个字"}
            ],
          })(
                              <TextArea type="textarea" style={{width:300}}/>
                          )}
                      </FormItem>
                      
                  </Form>
              </Modal>
          )
           }
           if(text == "土壤处理量统计表") {
            return (
              <Modal
                  destroyOnClose={true}
                  visible={visible}
                  title="新增记录"
                  okText="保存"
                  cancelText="关闭"
                  onCancel={onCancel}
                  onOk={onCreate}
              >
              
                  <Form layout="inline">
                      <FormItem label="日期">
                          {getFieldDecorator("cldate",data)(
                              <DatePicker size="small" placeholder="请选择日期"
                              disabledDate={this.disabledDate}
                              />
                          )}
                      </FormItem>
                      <FormItem label="时间">
                          {getFieldDecorator("times",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
               
            ],
          })(
                             <Select  style={{ width: 120 }} size="small">
                             <Option value="00:00-06:00">00:00-06:00</Option>
                             <Option value="06:00-12:00">06:00-12:00</Option>
                             <Option value="12:00-18:00">12:00-18:00</Option>
                             <Option value="18:00-00:00">18:00-00:00</Option>
                         </Select>
                          )}
                      </FormItem>
                      <FormItem label="班组">
                          {getFieldDecorator("banzu",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
               
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="土壤处理量/t">
                          {getFieldDecorator("throughput",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      
                      <FormItem label="记录人">
                          {getFieldDecorator("opertion",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
               
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="备注">
                          {getFieldDecorator("remarkText",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {max:20,message:"最多输入20个字"},
               
            ],
          })(
                              <TextArea type="textarea" style={{width:300}} />
                          )}
                      </FormItem>
                      
                  </Form>
              </Modal>
          )
           }
           if(text == "土壤修复指标汇总表") {
            return (
              <Modal
                  destroyOnClose={true}
                  visible={visible}
                  title="新增记录"
                  okText="保存"
                  cancelText="关闭"
                  onCancel={onCancel}
                  onOk={onCreate}
              >
              
                  <Form layout="inline">
                  <FormItem label="批次">
                          {getFieldDecorator("batches",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {max:15,message:"最多输入15个字"}
               
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="开始日期">
                          {getFieldDecorator("startTime",data)(
                              <DatePicker size="small"
                              disabledDate={this.disabledDate}
                              />
                          )}
                      </FormItem>
                      <FormItem label="开始时间">
                          {getFieldDecorator("startTime1",data)(
                              <TimePicker format={format}  size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="结束日期">
                          {getFieldDecorator("endTime",{
                                rules: [{
                                required: this.state.checkNick1,
                                message: '必填',
                                }],
                            })(
                             <DatePicker size="small"
                             disabledDate={this.disabledDate}
                             onChange={this.handleChange}
                             />
                          )}
                      </FormItem>
                      <FormItem label="结束时间">
                          {getFieldDecorator("endTime1",{
                                rules: [{
                                required: this.state.checkNick,
                                message: '必填',
                                }],
                            })(
                             <TimePicker format={format}
                             onChange={this.handleChange1}
                             size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="处理量/t">
                          {getFieldDecorator("throughput",{
            validateTrigger: [ 'onBlur'],
            rules: [
               
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="处理温度均值/℃">
                          {getFieldDecorator("processingTemperature",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem>
                      <FormItem label="停留时间">
                          {getFieldDecorator("waitTime",{
            validateTrigger: [ 'onBlur'],
            rules: [
               
                {pattern:/^[0-9]+([.]{1}[0-9]{1})?$/,message:'请输入数字及小数点后一位'}
            ],
          })(
                              <Input type="textarea" size="small"/>
                          )}
                      </FormItem><br/>
                      六氯苯<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing1",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing1",{
            validateTrigger: [ 'onBlur'],
            rules: [
                
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      硝基苯<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing2",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing2",{
            validateTrigger: [ 'onBlur'],
            rules: [
              
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      苯并(a)芘<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing3",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing3",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      苯并(a)蒽<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing4",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing4",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      三氯乙烯<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing5",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing5",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      1,4-二氯苯<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing6",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing6",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      污染物质7<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing7",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing7",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem><br/>
                      污染物质8<br/>
                      <FormItem label="处理前">
                          {getFieldDecorator("beforeProcessing8",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {required:true,message:"必填"},
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="处理后">
                          {getFieldDecorator("afterProcessing8",{
            validateTrigger: [ 'onBlur'],
            rules: [
             
                {pattern:/^[0-9]+([.]{1}[0-9]{1,2})?$/,message:'请输入数字及小数点后二位'}
            ],
          })(
                              <Input type="textarea" size="small" style={{width:130}}/>
                          )}
                      </FormItem>
                      <FormItem label="备注">
                          {getFieldDecorator("remarkText",{
            validateTrigger: [ 'onBlur'],
            rules: [
                {max:30,message:"最多输入20个字"},
               
            ],
          })(
                              <TextArea type="textarea" style={{width:300}}/>
                          )}
                      </FormItem>
                      
                  </Form>
              </Modal>
          )
           }
           
        }
    }
);

export default connect()(CollectionCreateForm);
